package com.andrew.demo.tableInfo;

import com.andrew.demo.model.Student;

import java.sql.ResultSet;
import java.sql.SQLException;

public class StudentTableInfoEntity extends BaseTableInfoEntity<Student> {

    public StudentTableInfoEntity() {
        super(DB_NAME, TABLE_NAME, SELECT_SQL, UPDATE_SQL);
    }

    public static String DB_NAME = "demo";

    public static String TABLE_NAME = "student";

    public static String SELECT_SQL = "select * from student";

    public static String UPDATE_SQL = "update student set (name,age,sex) values (:name,:age,:sex)";

    @Override
    public Student convert(ResultSet rs) throws SQLException {
        Integer id = rs.getInt("id");
        String name = rs.getString("name");
        Integer age = rs.getInt("age");
        String sex = rs.getString("sex");
        return new Student(id, name, age, sex);
    }

}
